package net.qhzw.vip.qiyu.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.qhzw.vip.qiyu.entity.ContractItem;
import net.qhzw.vip.qiyu.model.CarRentalCostsItem;
import net.qhzw.vip.qiyu.result.JsonResult;
import net.qhzw.vip.qiyu.service.ContractItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("contractItem")
@Api(tags = "合同详情")
public class ContractItemController {


    @Autowired
    private ContractItemService contractItemService;


    @ApiOperation(value = "结算费用明细")
    @PostMapping("chargeDetails")
    public JsonResult<CarRentalCostsItem> chargeDetails(@RequestBody ContractItem contractItem) {
        CarRentalCostsItem carRentalCostsItem = contractItemService.chargeDetails(contractItem);
        return JsonResult.ok(carRentalCostsItem);
    }


    @ApiOperation(value = "提交合同")
    @PostMapping("submit")
    public JsonResult submit(@RequestBody ContractItem contractItem) {
        boolean isOK = contractItemService.submit(contractItem);
        if (isOK) {
            return JsonResult.ok();
        }
        return JsonResult.fail();
    }


}
